<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>订单状态编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <style type="text/css">
        .productli{height:80px; width:340px; float:left;}
        .productimg{width:100px;height:65px; float:left; margin-right:5px;}
        .productdiv{color:#000; float:left;}
    </style>
</head>
<body>

<div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
	<div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">订单编号：</label>
      <div class="layui-input-inline" style="width:150px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="orderNo"></label>
      </div>
    </div>
	<div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">下单时间：</label>
      <div class="layui-input-inline" style="width:150px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="pOrderTime"></label>
      </div>
    </div>
	<div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">支付时间：</label>
      <div class="layui-input-inline" style="width:150px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="payTime"></label>
      </div>
    </div>
	<div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">物流时间：</label>
      <div class="layui-input-inline" style="width:150px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="deliveryTime"></label>
      </div>
    </div>	
    <div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">完成时间：</label>
      <div class="layui-input-inline" style="width:150px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="payFinishTime"></label>
      </div>
    </div>	
	<div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">订单状态：</label>
      <div class="layui-input-inline" style="width:150px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="orderStatus"></label>
      </div>
    </div>
    <div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">订单金额：</label>
      <div class="layui-input-inline" style="width:150px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="orderMoney"></label>
      </div>
    </div>
	<div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">配送费用：</label>
      <div class="layui-input-inline" style="width:150px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="freight"></label>
      </div>
    </div>
	<div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">是否发票：</label>
      <div class="layui-input-inline" style="width:150px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="isInvoice"></label>
      </div>
    </div>
	<div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">会员编号：</label>
      <div class="layui-input-inline" style="width:150px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="userNo"></label>
      </div>
    </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width:70px;">订单生成人：</label>
            <div class="layui-input-inline" style="width:150px;">
                <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="adminUserNo"></label>
            </div>
        </div>
	<!--<div class="layui-inline">-->
      <!--<label class="layui-form-label" style="width:70px;">运营成本：</label>-->
      <!--<div class="layui-input-inline" style="width:150px;">-->
        <!--<label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id=""></label>-->
      <!--</div>-->
    <!--</div>-->
	<div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">实际支付：</label>
      <div class="layui-input-inline" style="width:150px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="realPay"></label>
      </div>
    </div>
	<div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">积分支付：</label>
      <div class="layui-input-inline" style="width:150px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="inter"></label>
      </div>
    </div>
	<div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">消费积分：</label>
      <div class="layui-input-inline" style="width:150px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="costInter"></label>
      </div>
    </div>
	<div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">兑 换 券：</label>
      <div class="layui-input-inline" style="width:150px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="coupon"></label>
      </div>
    </div>
	<div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">抵 扣 券：</label>
      <div class="layui-input-inline" style="width:150px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="cashCoupon"></label>
      </div>
    </div>
	<div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">现金：</label>
      <div class="layui-input-inline" style="width:150px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="cash"></label>
      </div>
    </div>
	<!--<div class="layui-inline">-->
      <!--<label class="layui-form-label" style="width:70px;">支 付 宝：</label>-->
      <!--<div class="layui-input-inline" style="width:150px;">-->
        <!--<label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;">0</label>-->
      <!--</div>-->
    <!--</div>-->
	<!--<div class="layui-inline">-->
      <!--<label class="layui-form-label" style="width:70px;">返折扣券：</label>-->
      <!--<div class="layui-input-inline" style="width:150px;">-->
        <!--<label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;">2000</label>-->
      <!--</div>-->
    <!--</div>-->
	<!--<div class="layui-inline">-->
      <!--<label class="layui-form-label" style="width:70px;">返兑换券：</label>-->
      <!--<div class="layui-input-inline" style="width:150px;">-->
        <!--<label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;">0</label>-->
      <!--</div>-->
    <!--</div>-->
	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
		<legend>商品信息</legend>
	</fieldset> 
	<div class="layui-inline">
					<ul id="productul" style="margin:20px; ">
						<!--<li class="productli">-->
							<!--<img class="productimg"><div class="productdiv">商品名称1<br>数量:1<br>价额:1000</div>-->
						<!--</li>-->
						<!--<li style="clear:both;"></li>-->
					</ul>
	</div>
	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
		<legend>物流信息</legend>
	</fieldset> 
	<div>
	<!--<div class="layui-inline">-->
      <!--<label class="layui-form-label" style="width:70px;">商品信息：</label>-->
      <!--<div class="layui-input-inline" style="width:1200px;">-->
        <!--<label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;width:1200px;">商品名称1(1瓶),商品名称2(1件)</label>-->
      <!--</div>-->
    <!--</div>-->
	<div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">收货姓名：</label>
      <div class="layui-input-inline" style="width:150px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="logname"></label>
      </div>
    </div>
	<div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">联系电话：</label>
      <div class="layui-input-inline" style="width:150px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" id="phone"></label>
      </div>
    </div>
	<div class="layui-inline" style="width:530px;">
      <label class="layui-form-label" style="width:70px;">联系地址：</label>
      <div class="layui-input-inline" style="width:420px;">
        <label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;width:420px;" id="addressAll"></label>
      </div>
    </div>
	<div class="layui-inline">
      <label class="layui-form-label" style="width:70px;">物流信息：</label>
      <div class="layui-input-inline" id="loginfo" style="width:150px;">
        <!--<label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" onclick="WinOpenShow('LogisticalShow.html?id=2','物流信息',500,700);">已经到贵阳南明站</label>-->
          <!--<input type="button" class="layui-btn layuiadmin-btn-admin" value="1111">-->
      </div>
    </div>
	</div>
	<div>
	<!--<div class="layui-inline">-->
      <!--<label class="layui-form-label" style="width:70px;">商品信息：</label>-->
      <!--<div class="layui-input-inline" style="width:1200px;">-->
        <!--<label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;width:1200px;">商品名称3(1瓶),商品名称4(1件)</label>-->
      <!--</div>-->
    <!--</div>-->
	<!--<div class="layui-inline">-->
      <!--<label class="layui-form-label" style="width:70px;">联系姓名：</label>-->
      <!--<div class="layui-input-inline" style="width:150px;">-->
        <!--<label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;">姓名</label>-->
      <!--</div>-->
    <!--</div>-->
	<!--<div class="layui-inline">-->
      <!--<label class="layui-form-label" style="width:70px;">联系电话：</label>-->
      <!--<div class="layui-input-inline" style="width:150px;">-->
        <!--<label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;">18566662222</label>-->
      <!--</div>-->
    <!--</div>-->
	<!--<div class="layui-inline" style="width:530px;">-->
      <!--<label class="layui-form-label" style="width:70px;">联系地址：</label>-->
      <!--<div class="layui-input-inline" style="width:420px;">-->
        <!--<label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;width:420px;">贵州省 贵阳市 南明区 大西门1001号15-20</label>-->
      <!--</div>-->
    <!--</div>-->
	<!--<div class="layui-inline">-->
      <!--<label class="layui-form-label" style="width:70px;">物流信息：</label>-->
      <!--<div class="layui-input-inline" style="width:150px;">-->
        <!--<label class="layui-form-label layui-gray layui-input-inline" style="text-align:left; padding-left:0px;" onclick="WinOpenShow('LogisticalShow.html?id=2','物流信息',500,700);">已经到贵阳南明站</label>-->
      <!--</div>-->
    <!--</div>-->
	</div>
	<div class="layui-inline" style="padding:20px;">
		<!--<button class="layui-btn layuiadmin-btn-admin" data-type="add" onclick="WinOpenAdd('/order/order/orderLogisticalEdit.html?orderId=1','添加物流信息');">添加物流信息</button>-->
		<button class="layui-btn layui-btn-normal layui-btn-xs" data-type="add" onclick="WinOpenAdd();">添加换货信息</button>
	</div>
  </div>
</div>

<script src="/layui/jquery.min.js"></script>
<script src="/layui/layui.js"></script>
<script src="/js/common.js"></script>
<script>
    var orderId=0;
    var orderNo="";
    var logName="";
    var phone="";
    var detailAddr="";

    var provinceId="";
    var cityId="";
    var areaId="";
    var addressId=0;
    var remark="";
    var loggoodsinfo="";
$(function () {
    orderId = $.getUrlParam("orderId");
    var usernoName = $.getUrlParam("usernoName");
    $.ajax({
        url: '/goods?url=Order%2FgetDetails&orderId='+orderId+'',
        type: 'post',
        dataType: 'json',
        contentType: 'application/json',
        async: false,
        success: function(data){
            //$("#orderNo").html(JSON.stringify(data));return;
            var productInfo="";
            if(data.code=="000000"){
                remark=data.data.remark;
                orderNo=data.data.orderNo;
                logName=data.data.logname;
                phone=data.data.phone;
                detailAddr=data.data.detailAddr;
                provinceId=data.data.provinceId;
                cityId=data.data.cityId;
                areaId=data.data.areaId;
                addressId=data.data.addressId;
                $("#orderNo").html(data.data.orderNo);
                $("#pOrderTime").html(data.data.pOrderTime);
                $("#payTime").html(data.data.payTime);
                $("#deliveryTime").html(data.data.deliveryTime);
                $("#payFinishTime").html(data.data.payFinishTime);
                $("#orderStatus").html(data.data.orderStatusname);
                $("#orderMoney").html(data.data.orderMoney);
                $("#freight").html(data.data.freight);
                $("#isInvoice").html(data.data.isInvoicename);
                $("#userNo").html($.trim(usernoName));
                $("#realPay").html(data.data.realPay);
                $("#inter").html(data.data.inter);
                $("#costInter").html(data.data.costInter);
                $("#coupon").html(data.data.coupon);
                $("#cashCoupon").html(data.data.cashCoupon);
                $("#cash").html(data.data.cash);
                $.each(data.data.adminOrderDetails, function(i, item){
                    productInfo +="<li class='productli'>";
                    productInfo +="<img class='productimg' src='"+item.guigePic+"'>" +
                        "<div class='productdiv'>"+item.productName+item.guigeName+"<br>数量:"+item.productCount+"<br>价格:"+item.price+"</div>";
                    productInfo +="<li class='productli'>";

                    var s="";
                    if(item.logisticsType==1){
                        s="快递";
                    }
                    if(item.logisticsType==2){
                        s="自提";
                    }
                    loggoodsinfo +="<div style='margin-top: 5px;'><input  value='"+item.cartId+"' type='checkbox' " +
                        "name='goodsinfo' lay-filter='goodsinfo' title='类型："+s+"--"+item.guigeName+" 数量:"+item.productCount+" 价格:"+item.price+"' lay-skin='primary' checked ></div>";
                });
                productInfo +="<li style='clear:both;'></li>";
                $("#productul").html(productInfo);
                $("#logname").html(data.data.logname);
                $("#phone").html(data.data.phone);
                $("#addressAll").html(data.data.addressAll+data.data.detailAddr);
                var loginfo=data.data.logisticalNo;
                //loginfo="11111,2222"
                var infoStr="";
                for (var i=0;i<loginfo.split(",").length;i++){
                    var lno='\"'+loginfo.split(",")[i]+'\"';
                    infoStr +="<input type='button' onclick='getLogInfo("+lno+")' class='layui-btn layui-btn-xs' value='查看' data='"+loginfo[i]+"'>";
                }
                $("#loginfo").html(infoStr);
            }
        }
    });
});
var logNo="";
function getLogInfo(no){
    logNo =no;
    layer.open({
        type: 2
        , title: false
        , content: ['/order/order/LogisticalShow.html']
        , area: ['550px', '800px']
        // , btn: ['确定', '取消']
        , yes: function (index, layero) {
        }
    });


};

    // var table;
    // layui.use('table', function(){
    //     table = layui.table,form = layui.form;
    //
    //     table.render({
    //         elem: '#test'
    //         ,url:'/Order?url=Order%2FgetDetails'
    //         ,cellMinWidth:80
    //         ,cols: [[
    //             {type:'numbers'}
    //             ,{type: 'checkbox'}
    //             ,{field:'orderNo',width:200,title:'订单编号', templet: '#barNo', unresize: true}
    //             ,{field:'orderMoney', title:'订单金额'}
    //             ,{field:'realPay', title:'实际支付'}
    //             ,{field:'orderStatus',title:'订单状态', templet: '#barStatus', unresize: true}//orderStatusName
    //             ,{field:'usernoName', title: '用户编号'}
    //             ,{field:'logname', title: '收货姓名'}
    //             ,{field:'phone',width:150, title: '收货电话'}
    //             ,{field:'addressAll',width:300, title: '收货地区', templet: '#barAddr', unresize: true}
    //             // ,{field:'logisticalTypeName', title: '物流类型', templet: '#barLogistical', unresize: true}
    //             ,{field:'pOrderTime',width:200,title: '下单时间'}
    //             ,{field:'order', title:'编辑', templet: '#barDemo', unresize: true}
    //         ]]
    //         ,page: true
    //         ,id: 'testReload'
    //     });
    //
    //     //监听表格复选框选择
    //     table.on('checkbox(demo)', function(obj){
    //         console.log(obj)
    //     });
    // });


    layui.config({
        base: '/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function(){
        var $ = layui.$
            ,form = layui.form ;
    })
	
	function WinOpenShow(u,t,w,h) {
        layer.open({
            type: 2
            , title: t
            , content: u
            , area: [w+'px', h+'px']
        });
    }
	
	function WinOpenAdd() {
        //'/order/order/orderLogisticalEdit1.html?orderId=1','添加换货信息'
        //window.parent.WinOpenShow("/order/order/orderEditAddress.html?orderId="+orderId,"修改物流地址",550,800);
        //content: ['test/guodu.html', 'no'], //iframe的url，no代表不显示滚动条
        layer.open({
            type: 2
            , title: false
            , content: ['/order/order/orderEditAddress.html?orderId='+orderId, 'no']
            , area: ['550px', '800px']
            , btn: ['确定', '取消']
            , yes: function (index, layero) {
                var body = layer.getChildFrame('body', index);
                var logType=window[layero.find('iframe')[0]['name']].logType;
                var logGoodsInfo=window[layero.find('iframe')[0]['name']].logGoodsInfo;

                // alert(logGoodsInfo+"---"+logGoodsInfo.split(",").length+" logType:"+logType);
                // return;
                var  provinceIdBody=window[layero.find('iframe')[0]['name']].provinceId;
                var  cityId=window[layero.find('iframe')[0]['name']].cityId;
                var  areaId=window[layero.find('iframe')[0]['name']].areaId;
                var  logName=window[layero.find('iframe')[0]['name']].logName;
                var  phone=window[layero.find('iframe')[0]['name']].phone;
                var  detailAddr=window[layero.find('iframe')[0]['name']].detailAddr;
                var  remark=window[layero.find('iframe')[0]['name']].remark;
    var url='/goods?url=Order%2FeditAddressInfo' +
    '&addressId='+addressId+
    '&cityId='+cityId+
    '&provinceId='+provinceIdBody+
    '&areaId='+areaId+
    '&logName='+logName+
    '&phone='+phone+
    '&detailAddr='+detailAddr+
    '&remark='+remark+
        '&logType='+logType+
        '&logGoodsInfo='+logGoodsInfo+
    '&orderNo='+orderNo;

                 var htmlobj=$.ajax({
                     url:url,
                     type: 'post',
                     async:false,
                     dataType: 'json',
                     contentType: 'application/json',
                 });
                 var info=JSON.stringify(htmlobj);
                  if(htmlobj.responseJSON.code=="000000"){
                      parent.alert(htmlobj.responseJSON.errorDetail);
                      layer.close(index); //关闭弹层
                      // $.toast(htmlobj.responseJSON.errorDetail,1000, function() {
                      //     layer.close(index); //关闭弹层
                      //     //window.location.href="/wap/openUserCenter";
                      // });

                  }else {
                      parent.alert(htmlobj.responseJSON.errorDetail);
                      layer.close(index); //关闭弹层
                  }
// //数据刷新
//                 var demoReload = $('#demoReload');
//                 //执行重载
//                 table.reload('testReload', {
//                 });

                //debugger;
                /*
				var body = layer.getChildFrame('body', index); //得到iframe页的body内容
                var userName = body.find("#userName").val();
                var phone = body.find("#phone").val();
                var cardId = body.find("#cardId").val();
                var recommend = body.find("#recommend").val();
                var sort = body.find("#sort").val();

                var addUrl="/user/addUser?userName="+userName+"&phone="+phone+"&cardId="+cardId+"&recommend="+recommend+"&sort="+sort;
                alert(addUrl);
                // var htmlobj=$.ajax({url:addUrl,async:false});
                alert(htmlobj);
                //数据刷新
                var demoReload = $('#demoReload');
                //执行重载
                table.reload('testReload', {
                });
*/

            }
            , end: function () {
                location.reload();
            }
        });
    }
	
</script>
</body>
</html>